//
//  BaseButton.m
//  SHShopping
//
//  Created by 坤鼎 on 2019/8/26.
//  Copyright © 2019 kunding. All rights reserved.
//

#import "BaseButton.h"

@implementation BaseButton

+ (Class)layerClass {
    return [CAShapeLayer class];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 10;
        self.layer.masksToBounds = YES;
        ((CAShapeLayer *)self.layer).fillColor = LHYPlaceholderColor.CGColor;
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
//    自定义半角
//    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft cornerRadii:CGSizeMake(20,20)];
//    全角
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:self.layer.cornerRadius];
    
    ((CAShapeLayer *)self.layer).path = maskPath.CGPath;
}

- (void)setBackgroundColor:(UIColor *)backgroundColor {
    ((CAShapeLayer *)self.layer).fillColor = backgroundColor.CGColor;
}



@end
